//
//  UITextView+Extension.swift
//  SwiftProject
//
//  Created by qindong on 2021/6/15.
//

import Foundation

extension QMUITextView {
    private struct AssociatedKey {
        static var identifier: String = "identifier"
    }
    
    /// 是否出现长按菜单
    var canShowAction : Bool {
        get {
            objc_getAssociatedObject(self, &AssociatedKey.identifier) as? Bool ?? true
        }
        set {
            objc_setAssociatedObject(self, &AssociatedKey.identifier, newValue, .OBJC_ASSOCIATION_RETAIN)
        }
    }
    
    open override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
        canShowAction == false ? canShowAction : super.canPerformAction(action, withSender: sender)
    }
    
    open override var canBecomeFirstResponder: Bool {
        canShowAction == false ? canShowAction : super.canBecomeFirstResponder
    }
}
